<template>
  <!--车辆终身质保审核-->
  <div>
    <!--<TopFilter :list="topFilterList" :cols="4" :collapse="false" @filterChange="changeHandle"-->
               <!--@onCollapse="collapseHandle"></TopFilter>-->
    <FilterTable
      selectionType="single"
      :onRowSelectChange="selectChange"
      ref="table" :columns="columns" :fetchapi="fetchApi" :params="fetchParams" datakey="records"
      :isSelectColumn="true" :onColumnsChange="columns => (this.columns = columns)">
    </FilterTable>

    <div class="dialogBottmView">
      <el-button size="small" type="primary" class="btnStyle" @click="closeMenu('1')">确定
      </el-button>

      <el-button size="small" type="primary" class="btnStyle" @click="closeMenu('2')">关闭
      </el-button>
    </div>

  </div>
</template>

<script>
  import {mapState} from 'vuex';
  import {dictionary} from '@/utils/dictMixin';
  import moment from 'moment';

  import { getAllBrand, getAllSeries,getAllModel} from '@/api/repair/batchEventManagement/activityExecutionStatusQueryJingxsDuan';
  import {isEmpty} from '@/utils/utils';
  import {byAllInfo} from '@/api/repair/newEnergyVehicleLifetime/vehicleLifetimeReviewQueryJingxsDuan';
  import {arrayObjDeWeight} from '@/utils';

  export default {
    name: 'addItem',
    mixins: [dictionary],
    data()
    {
      this.BaseTable = null;
      this.conf = {add: '新增', edit: '编辑', show: '审核'};
      return {
        topFilterList: this.createTopFilterList(),
        visible: false,
        fetchApi: getAllModel,
        dialogTitle: '',
        fetchParams: {xhrAbort: false},
        columns: this.createTableColumns(),
        selectArr: []
      };
    },
    components: {},

    mounted()
    {
      this.BaseTable = this.$refs.table.$refs.pageTable;

    },
    methods: {
      selectChange(val)
      {
        this.selectArr = val
        console.log(val)
      },

      createTableColumns()
      {
        return [
          {
            title: '序号',
            dataIndex: 'index',
            width: 70,
            sorter: true,
            render: props =>
            {
              return <span>{props.row.index + 1}</span>;
            }
          },
          {
            title: '车型code',
            dataIndex: 'modelCode',
            width: 150,
            sorter: true,
            filter: true,
            filterType: 'input',

          },
          {
            title: '车型',
            dataIndex: 'modelName',
            width: 150,
            sorter: true,
            filter: true,
            filterType: 'input'
          }
        ];
      },
      createTopFilterList()
      {
        return [
          {
            type: 'INPUT',
            label: '车型code',
            fieldName: 'modelCode',
            placeholder: '品牌...'
          },
          {
            type: 'INPUT',
            label: '车型',
            fieldName: 'modelName',
            placeholder: '车型...'
          },
        ];
      },

      collapseHandle()
      {
        this.$nextTick(() =>
        {
          this.BaseTable.EXECUTE_RESET_HEIGHT();
        });
      },


      changeHandle(val)
      {
        // val.bDate=moment(val['bDate']).format('YYYY-MM-DD')
        // val.eDate=moment(val['eDate']).format('YYYY-MM-DD')
        this.fetchParams = Object.assign({}, val);

        console.log(this.fetchParams)
      },
      async closeMenu(type)
      {
        if (type == '1')
        {
          this.$emit('selectArr', this.selectArr)
        }
        this.$emit('close')
      },
    }
  };
</script>

<style lang="less" scoped>
  .bg1 {
    border: 1px solid @borderColor;
    border-radius: @borderRadius;
    box-shadow: @boxShadow;
    padding: @modulePadding;
    padding-left: 0;
    padding-top: 15px;
    padding-bottom: 15px;
  }

  .bg2 {
    margin-top: 10px;
    margin-bottom: 10px;
  }

  .btn {
    text-align: center;
  }

  .btnStyle {
    margin-top: 10px;
  }

</style>

